Skip to content

chore(mix_generator): clear the DCM backlog in mix_generator and mix_annotations - #1032

Merged
leoafarias merged 1 commit into
mainfrom
chore/dcm-lint-cleanup
Aug 19, 2026
Merged

chore(mix_generator): clear the DCM backlog in mix_generator and mix_annotations#1032
leoafarias merged 1 commit into
mainfrom
chore/dcm-lint-cleanup

Conversation

@leoafarias

Copy link
Copy Markdown
Member

What

melos run analyze failed on mix_generator (10 issues) and mix_annotations (1). This clears both, so melos run analyze passes across the workspace for the first time.

Split out of #1031, which is unrelated grid work — these files aren't touched there.

Why it accumulated

CI never runs DCM. .github/workflows/test.yml runs format:check, schema:inventory, analyze:dart, and ci, with a comment explaining the omission: "DCM requires CI credentials." So melos run analyze:dcm only ever runs on someone's laptop, and there are no git hooks in the repo. Worth a follow-up decision — see below.

For the record, the rest of the local-lint surface was already clean: dart format --set-exit-if-changed reports 0 changed files across all 11 packages plus scripts, and dart fix --dry-run reports "Nothing to fix!" in every package. This is DCM-only.

Mechanical (via dcm fix)

Four missing blank line before return, one member-ordering.

Judgement calls

MixWidgetBuilder interpolated a nullable targetTypeReference into the generated widget name. Guarded by hasDirectTarget, so it couldn't actually be null — but nothing made that checkable, and a null would have emitted null(...) as a widget name in generated code. Now bound at the call site with a pattern match and passed in non-null. hasDirectTarget had no consumers left afterward, so it's removed rather than left dead.

_targetStyleAcceptsRecipe interpolated a nullable spec.name into a type string it then compares against. Both remaining checks match the spec by name, so an unnamed element can never match — hoisted the name and returned false when absent.

The "must include required factory parameter" diagnostic interpolated a nullable parameter name, so a wildcard (_) parameter would have produced parameter `null` . Falls back to the analyzer's displayName.

MixWidget.target keeps Function?. A constructor tear-off's signature differs per annotation, so no explicit function type fits, and Object? would drop the callable signal. MixableSpec.target already carried this exact ignore; MixWidget.target had simply been missed. Added with the rationale.

_extractFactoryParams built availableNames unconditionally though it's only read in the !includesAll branch — moved inside it.

Verification

  • melos run gen:build regenerates every package byte-for-byte identically — no behavior change, which is the point that matters for a generator refactor
  • melos run analyze — SUCCESS (dart + DCM + schema inventory), previously FAILED
  • melos run ci — all green (mix 2892, mix_winds 532, mix_protocol 391, mix_generator 377, mix_chart 52, mix_lint 37, + examples)
  • melos run format:check — clean

No CHANGELOG entries: generated output is unchanged, so nothing here is user-visible.

Follow-up worth deciding

These will drift back. With DCM intentionally out of CI, the only enforcement point is local, and the repo has no git hooks at all — no husky, no lefthook, no core.hooksPath. Options are DCM CI credentials, or a pre-commit/pre-push hook running melos run analyze:dcm. Happy to wire up whichever you prefer.

…annotations

`melos run analyze` failed on these two packages. CI never caught it: the test
workflow runs analyze:dart but deliberately skips analyze:dcm because DCM needs
CI credentials, so the backlog only surfaced when someone ran it locally.

`dcm fix` handled five mechanical issues (four blank-line-before-return, one
member ordering). The rest needed a decision:

- MixWidgetBuilder interpolated a nullable targetTypeReference into the
  generated widget name. It was guarded by `hasDirectTarget`, so it could not
  actually be null, but nothing made that checkable. Bind the value at the call
  site instead and pass it in non-null; a null there would have emitted
  `null(...)` as a widget name. `hasDirectTarget` had no consumers left, so it
  is gone rather than left dead.
- _targetStyleAcceptsRecipe interpolated a nullable spec.name into a type
  string it then compares. Both remaining checks match by name, so an unnamed
  element can never match: hoist the name and return false when it is absent.
- The "must include required factory parameter" diagnostic interpolated a
  nullable parameter name and would have read "parameter `null`" for a wildcard
  parameter. Fall back to the analyzer's displayName.
- MixWidget.target keeps `Function?`: a constructor tear-off's signature differs
  per annotation, so no explicit function type fits, and Object? would drop the
  callable signal. MixableSpec.target already carried this ignore; MixWidget's
  had just been missed. Added with the rationale.

No behavior change: a full `melos run gen:build` regenerates every package
byte-for-byte identically.
@leoafarias
leoafarias merged commit f13f3a0 into main Aug 19, 2026
9 of 11 checks passed
@leoafarias
leoafarias deleted the chore/dcm-lint-cleanup branch August 19, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant